:root {
  color-scheme: dark;
  --ink: #191e1b;
  --cream: #f5ecd9;
  --brass: #daba7c;
  --line: #535346;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: #161a17; }
body {
  margin: 0; color: var(--cream); font-family: var(--sans); line-height: 1.5;
  background: radial-gradient(ellipse at 56% 20%, #2c3128 0%, #1c211d 54%, #161a17 95%);
}
button, input, select { font: inherit; }
button { color: inherit; border: 1px solid #76694f; background: #30352c; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid #ffe29d; outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.topbar { background: #171c18; border-bottom: 1px solid #45483a; }
.topbar-inner, main { width: min(1320px, calc(100% - clamp(32px, 7vw, 100px))); margin: 0 auto; }
.topbar-inner { min-height: 65px; display: flex; gap: 24px; align-items: center; }
.brand { display: flex; gap: 11px; align-items: center; font: 700 20px/1 var(--display); letter-spacing: -.065em; white-space: nowrap; }
.seal { display: grid; place-items: center; width: 34px; height: 34px; background: #a44930; color: #ffe6b1; border: 1px solid #d18555; border-radius: 3px; box-shadow: inset 0 0 0 2px #93412e, inset 0 0 0 3px #d28a5e; font: 23px/1 var(--display); }
.camp-nav { display: flex; gap: 25px; align-self: stretch; margin-left: 22px; }
.camp-nav a, .camp-nav button { display: flex; align-items: center; position: relative; text-decoration: none; color: #aeafa0; font-size: 14px; }
.camp-nav button { padding: 0; background: none; border: 0; }
#fieldGallery { padding-block:12px; }
#galleryBack { margin-bottom:8px; min-height:36px; padding-inline:12px; }
#fieldGallery iframe { display:block; width:100%; height:calc(100dvh - 160px); min-height:320px; border:1px solid #645d4b; }
.camp-nav button:enabled:hover { color: #f4d9a3; }
.camp-nav button:disabled { opacity: .55; }
.camp-nav [aria-current], .camp-nav a:hover { color: #f4d9a3; }
.camp-nav [aria-current]::after { position: absolute; content: ""; inset: auto 0 0; height: 2px; background: #cda66a; }
.purse, .roster-size { display: flex; align-items: center; gap: 8px; color: #bdc0ae; font-size: 13px; white-space: nowrap; }
.purse { margin-left: auto; }
.purse strong, .roster-size strong { color: #f4e7cd; font: 700 19px/1.2 var(--sans); font-variant-numeric: tabular-nums; }
.purse strong { color: #f2cc80; }
.roster-size { padding-left: 22px; border-left: 1px solid #545444; }
.cash-icon { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: #c8a55e; border: 1px solid #e2c985; box-shadow: inset 0 0 0 2px #ab8849; }
.cash-icon::after { content: ""; width: 4px; height: 4px; background: #3f3a28; }
main { padding: 20px 0 50px; }
.masthead { position: relative; isolation: isolate; display: flex; align-items: flex-end; min-height: clamp(154px, 14vw, 195px); overflow: hidden; border: 1px solid #70644d; background: #302a20; }
.masthead::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg,#131b16c9 0%,#191d1550 38%,transparent 65%), url("군영 막사 풍경.webp") 50% 59%/cover; }
.masthead-copy { padding: 22px clamp(20px, 3.2vw, 46px); text-shadow: 0 2px 7px #10160f; }
.masthead h1 { margin: 0; color: #fff0ce; font: 700 clamp(42px, 4.25vw, 62px)/1.08 var(--display); letter-spacing: -.015em; }
.masthead p { margin: 9px 0 0; color: #e5dec7; font-size: clamp(13px, 1.1vw, 16px); }
.run-result {
  --result-accent: #efa581; --result-button: #793c2f;
  position: fixed; inset: 0; margin: auto; padding: 0;
  width: min(570px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  overflow: auto; color: #f7ead6; background: #21231d;
  border: 1px solid #897150; border-top: 3px solid var(--result-accent);
  box-shadow: 0 20px 80px #060906ab;
}
.run-result::backdrop { background: #0c100dd9; }
.result-illustration {
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid #80614d;
  background: #1c2734 url("result-defeat.webp") center / contain no-repeat;
}
.run-result[data-outcome="victory"] { --result-accent: #efd490; --result-button: #62512f; }
.run-result[data-outcome="victory"] .result-illustration {
  border-color: #9b8459; background-color: #5a4a27; background-image: url("result-victory.webp");
}
.run-result-copy { padding: clamp(15px,4vw,30px) clamp(18px,5vw,38px) clamp(19px,4vw,32px); }
#runResultWave { margin: 0 0 3px; font-weight: 650; color: #e6d8ba; }
.run-result h1 { margin: 0; color: var(--result-accent); font: 700 clamp(34px, 7vw, 62px)/1.15 var(--display); }
#runResultCause { margin: 6px 0 0; color: #fff0d6; font: 700 clamp(17px, 3vw, 24px)/1.4 var(--display); }
.run-result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: clamp(14px, 3vw, 22px) 0; padding: 11px 0; border-block: 1px solid #736952; }
.run-result-stats div { padding-inline: clamp(7px, 2vw, 20px); border-left: 1px solid #575744; }
.run-result-stats div:first-child { padding-left: 0; border: 0; }
.run-result-stats dt { color: #d4d3bd; font-size: 13px; }
.run-result-stats dd { margin: 4px 0 0; color: #fff1d5; font: 700 clamp(17px, 3vw, 25px)/1.3 var(--sans); font-variant-numeric: tabular-nums; }
#restartRun { width: 100%; min-height: 47px; padding: 9px 18px; border: 1px solid var(--result-accent); background: var(--result-button); color: #fff2d7; font: 700 18px/1.4 var(--display); }
#restartRun:hover { filter: brightness(1.15); }
@media (max-height: 500px) {
  .run-result-copy { padding-block: 10px; }
  .run-result-stats { margin: 8px 0; padding: 5px 0; }
}
@media (min-width: 540px) and (max-height: 500px) {
  .run-result[open] { display: grid; width: min(850px, calc(100% - 24px)); grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; }
  .run-result .result-illustration { border-bottom: 0; }
  .run-result-copy { padding-inline: clamp(12px, 3vw, 28px); }
}
.command-layout { display: grid; grid-template-columns: minmax(0,1fr) clamp(270px, 24%, 310px); gap: 18px; align-items: start; margin-top: 18px; }
.camp-aside { display: grid; gap: 14px; min-width: 0; }
.board { min-width: 0; padding: clamp(16px, 1.8vw, 27px); background: linear-gradient(125deg,#2d332a,#252b24 57%,#222820); border: 1px solid #625e4b; border-top: 2px solid #c4a46e; }
.board-heading, .board-title, .fortress { display: flex; align-items: center; }
.board-heading { justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.board-title { gap: 13px; flex-wrap: wrap; }
.board-title h2, .field-guide h2 { margin: 0; color: #f5e8cd; font-family: var(--display); letter-spacing: -.065em; }
.board-title h2 { font-size: clamp(24px, 2.05vw, 32px); line-height: 1.25; }
#stage { white-space: nowrap; color: #dfc591; border: 1px solid #6b654e; padding: 3px 8px; background: #252a22; font-size: 12px; font-variant-numeric: tabular-nums; }
.fortress { justify-content: end; gap: 6px; flex-wrap: wrap; font-size: 12px; color: #c2c5b2; }
.fortress b { color: #dfebc7; font-variant-numeric: tabular-nums; }
#campDifficulty { margin-right: 3px; padding-right: 8px; border-right: 1px solid #62644d; color: #dec48c; }
.fortress meter { width: 42px; height: 5px; border: none; appearance: none; background: #414737; }
.fortress meter::-webkit-meter-bar { height: 5px; background: #414737; border: 0; border-radius: 0; }
.fortress meter::-webkit-meter-optimum-value { background: #a3b789; }
.fortress meter::-moz-meter-bar { background: #a3b789; }
.machine { padding: 8px 8px 10px; border: 1px solid #776748; background: linear-gradient(110deg,#242722,#191e19 66%,#292922); box-shadow: inset 0 0 0 3px #393930; }
.drums { min-width: 0; }
.grid { display: grid; grid-template-columns: 33px repeat(2,minmax(0,1fr)) minmax(0,1.08fr) minmax(0,2.05fr); }
.labels { padding: 4px 0 9px; color: #d6c8a6; font-size: 12px; text-align: center; font-weight: 700; }
.labels span:first-child { color: #aeaa93; font-weight: normal; }
.labels span:last-child { text-align: left; padding-left: 23px; color: #ebd29e; }
#rows { display: grid; gap: 7px; }
.row { position: relative; height: clamp(70px, 5.6vw, 84px); background: #282e25; }
.row[tabindex="0"] { cursor: pointer; }
.row[tabindex="0"]:is(:hover,:focus-visible) { outline: 2px solid #d9b978; outline-offset: 1px; z-index: 1; }
.line-no { display: grid; place-items: center; background: #2e3329; color: #caba93; font: 12px/1 var(--sans); font-variant-numeric: tabular-nums; border-block: 1px solid #484b3e; }
.cell { min-width: 0; position: relative; display: block; height: 100%; overflow: hidden; isolation: isolate; }
.track { display: block; height: 100%; }
.row .cell, .lock .cell { color: #3c3324; background: linear-gradient(#b5a383 0%,#e0d3b5 10%,#f5ebd2 29%,#efe2c4 69%,#d6c5a4 88%,#a99777 100%); }
.row .cell { border-inline-start: 1px solid #9a896b; }
.row .move { border-radius: 3px 0 0 3px; }
.row .gear { border-radius: 0 3px 3px 0; }
.symbol { display: flex; align-items: center; justify-content: center; gap: clamp(4px,.6vw,9px); height: 100%; overflow: hidden; }
.rune, .recruit-art, .field-guide img { display: block; object-fit: contain; image-rendering: pixelated; flex: none; pointer-events: none; }
.rune { width: clamp(37px,4.1vw,60px); height: 84%; }
.rune-label { font-size: clamp(13px,1.15vw,17px); line-height: 1.25; letter-spacing: -.04em; font-weight: 700; }
.normal { --tint: #645a45; }
.water { --tint: #20557e; }
.fire { --tint: #a23f2b; }
.wind { --tint: #336443; }
.stamp { display: block; margin-top: 3px; color: var(--tint); font: 700 11px/1.1 var(--sans); }
.row[data-phase=ready] .rune { opacity: .84; }
.result { display: flex; align-items: center; min-width: 0; }
.row .result { --edge: #7a785d; position: relative; margin-left: 5px; padding: 0 12px 0 5px; border: 1px solid #494e3f; border-left: 3px solid var(--edge); background: linear-gradient(105deg,#444838,#30382c 67%); }
.row[data-element="물"] .result { --edge: #80bad5; background: linear-gradient(105deg,#364b4b,#2b3530 73%); }
.row[data-element="불"] .result { --edge: #e38a62; background: linear-gradient(105deg,#564134,#36342b 73%); }
.row[data-element="바람"] .result { --edge: #aac68c; background: linear-gradient(105deg,#40543b,#2d382a 73%); }
.row[data-phase=ready] .result, .row[data-phase=spinning] .result { border-left-color: #62634f; background: repeating-linear-gradient(135deg,#ffffff03 0 1px,transparent 1px 8px),#292e27; }
.placeholder { display: flex; align-items: center; gap: 13px; padding-left: 12px; color: #bcbdab; font-size: 13px; }
.placeholder::before { content: "◇"; color: #a59b78; font: 21px/1 var(--display); }
.zoom-cue { display: inline-block; margin-left: 4px; color: #c1c6ad; font: 500 11px/1.3 var(--sans); white-space: nowrap; }
.row[tabindex="0"] .result::after { content: ""; position: absolute; right: 6px; top: 6px; width: 14px; height: 14px; color: #d5c59e; background: radial-gradient(circle at 5px 5px, transparent 3px, currentColor 3.4px 4.5px, transparent 5px) no-repeat, linear-gradient(45deg, transparent 37%, currentColor 40% 61%, transparent 65%) 8px 8px / 6px 6px no-repeat; }
.row[aria-expanded="true"] { z-index: 1; outline: 3px solid #ffd17f; outline-offset: 1px; box-shadow: 0 0 0 5px #171c16; }
.row[aria-expanded="true"] .line-no { background: #88482d; color: #ffe5a6; }
.row[aria-expanded="true"] .result { border-color: #ceab69; }
.padlock { --lock-body: #a7aa99; --shackle: #d4d5c3; position: relative; display: inline-block; width: 21px; height: 23px; flex: none; }
.padlock::before { content: ""; position: absolute; top: 2px; left: 8px; width: 8px; height: 9px; border: 2px solid var(--shackle); border-bottom: 0; border-radius: 7px 7px 0 0; transform: translate(2px,-1px) rotate(21deg); transform-origin: bottom left; transition: transform .18s ease, border-color .18s; }
.padlock::after { content: ""; position: absolute; bottom: 2px; left: 3px; width: 15px; height: 11px; border-radius: 2px; background: radial-gradient(circle at 50% 39%,#35392d 1.5px,transparent 2px), linear-gradient(#35392d,#35392d) 50% 74% / 2px 4px no-repeat, var(--lock-body); box-shadow: inset 0 1px 0 #fff3; }
.lock[aria-pressed="true"] .padlock { --lock-body: #f3c66d; --shackle: #ffe0a2; }
.lock[aria-pressed="true"] .padlock::before { transform: translate(-2px,2px); }
.lock:disabled:not([aria-pressed="true"]) .padlock { opacity: .73; }
#zoom[data-mode="inspect"] .lock-action { display: none; }
.recruit-art { width: clamp(52px, 5vw, 75px); height: min(100%,75px); }
.recruit-copy { display: flex; flex-direction: column; min-width: 0; }
.name { display: flex; align-items: center; gap: 7px; color: #fff2d9; white-space: nowrap; font: 700 clamp(18px,1.55vw,23px)/1.25 var(--display); letter-spacing: -.06em; }
.element { display: inline-block; font: 700 10px/1.4 var(--sans); padding: 0 4px; letter-spacing: 0; color: #e2d5b4; background: #514c3b; border: 1px solid #8b8061; }
.element.fire { color: #ffd2af; border-color: #a16950; background: #613f30; }
.element.water { color: #c7edff; border-color: #638f9d; background: #354c54; }
.element.wind { color: #dcf2bb; border-color: #7e9765; background: #3f5236; }
.stats { display: flex; flex-wrap: wrap; gap: 1px 6px; margin-top: 4px; color: #d0d3c0; font: 12px/1.3 var(--sans); }
.stats span { white-space: nowrap; }
@keyframes arrive { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
@keyframes stop { 0% { background-color: #fff4b994; } 100% { background-color: transparent; } }
.row[data-phase=drawn] .recruit-art { animation: arrive .25s ease-out; }
.cell.landed::after { content: ""; position: absolute; inset: 0; pointer-events: none; animation: stop .28s ease-out; }
.cord-track { position: relative; display: flex; justify-content: center; --travel: 0px; }
.cord-track::before { content: ""; position: absolute; width: 6px; top: 0; height: calc(37px + var(--travel)); border: 1px solid #7f6438; background: repeating-linear-gradient(35deg,#9f753b 0 2px,#ead097 2px 5px); }
.cord-track::after { content: ""; position: absolute; inset: 97px 4px auto; border-top: 1px dashed #b6a074; }
.knob { position: relative; align-self: start; z-index: 1; width: 42px; height: 42px; margin-top: 34px; padding: 0; border: 2px solid #d7ae68; border-radius: 50%; background: radial-gradient(ellipse at 35% 30%,#bc6a42,#8e432e 65%); color: #ffe7b5; box-shadow: inset 0 0 0 2px #86452e, inset 0 0 0 3px #cd915a, 0 3px 2px #171912; font: 22px/1 var(--sans); cursor: grab; transform: translateY(var(--travel)); touch-action: none; user-select: none; }
.knob:active { cursor: grabbing; }
.knob:disabled { filter: saturate(.45); opacity: .70; }
.cord-track.ready .knob { background: #456446; border-color: #eecc83; }
.actions { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; margin-top: 17px; }
.actions button,.actions a { display: inline-flex; gap: 7px; align-items: center; justify-content: center; min-height: 44px; padding: 6px 17px; border: 1px solid #706951; background: #343a2f; border-radius: 3px; color: #f1e3c7; font: 700 14px/1.4 var(--sans); text-decoration: none; }
.actions button:enabled:hover,.actions a:hover { filter: brightness(1.16); }
.actions #summon, .board[data-step=review] #deployBatch { background: #a64b32; border-color: #d48657; box-shadow: inset 0 1px #d17c50; color: #fff0d3; }
.board[data-step=review] #summon { color: #eadfc6; background: #35392e; border-color: #726b53; box-shadow: none; }
.actions #buyRecruit { margin-left: auto; }
.actions #buyRecruit .cash-icon { width: 13px; height: 13px; }
.actions button:disabled, .actions #summon:disabled { border-color: #515448; color: #a6a896; background: #2b3029; box-shadow: none; }
.actions #deployBatch span { color: #f6d79d; }
#resultShelf:not([hidden]),.hint { display: inline; font-size: 13px; color: #c5c8b7; line-height: 1.6; }
.actions { margin-bottom: 12px; }
#rerollStatus { color: #e0c793; font-weight: 700; margin-right: 8px; }
.hint { margin: 0; }
#paidResult, #settlement { margin: 12px 0 0; padding: 8px 12px; border-left: 2px solid #b39459; background: #30372b; color: #e4dbbc; }
#paidResult, #paidResult .result { display: flex; align-items: center; gap: 10px; }
.receipt-label,#settlement { font-size: 13px; }
.field-guide { padding: 15px 19px 8px; background: #272d25; border: 1px solid #505344; }
.field-guide h2 { font-size: 19px; line-height: 1.3; padding-bottom: 9px; }
.field-guide dl, .field-guide dd { margin: 0; }
.field-guide dl > div { display: flex; align-items: center; justify-content: space-between; min-height: 40px; gap: 5px; border-top: 1px solid #454b3d; }
.field-guide dt { display: flex; align-items: center; gap: 9px; color: #eee5d0; font-weight: 700; font-size: 14px; }
.field-guide img { width: 40px; height: 40px; }
.field-guide dd { color: #c6c4ae; font-size: 12px; }
#training, #armyLog { margin-top: 15px; }
@media (max-width: 1100px) and (min-width: 851px) {
  .command-layout { grid-template-columns: minmax(0,1fr) 256px; gap: 12px; }
  .board { padding: 14px; }
  .grid { grid-template-columns: 25px repeat(2,minmax(0,.95fr)) minmax(0,1.07fr) minmax(0,1.98fr); }
  .row .symbol { flex-direction: column; gap: 0; }
  .row .rune { width: 40px; height: 42px; }
  .row .rune-label { display: flex; align-items: center; gap: 3px; font-size: 12px; }
  .row .stamp { margin: 0; font-size: 10px; }
  .row .recruit-art { width: 45px; }
  .row .result { padding-right: 4px; }
  .row .stats { font-size: 10px; }
}
@media (max-width: 850px) {
  .topbar-inner, main { width: calc(100% - 32px); }
  .command-layout { grid-template-columns: minmax(0,1fr); gap: 12px; margin-top: 12px; }
  .camp-aside { display: contents; }
  #nationDraw { grid-row: 1; }
  .board { grid-row: 2; }
  .field-guide { grid-row: 3; }
  .field-guide dl { display: grid; grid-template-columns: repeat(2,1fr); column-gap: 24px; }
  .masthead { min-height: 140px; }
  .topbar-inner { gap: 15px; }
  .camp-nav { margin-left: 7px; gap: 16px; }
  .roster-size { padding-left: 13px; }
}
@media (max-width: 600px) {
  .topbar-inner, main { width: calc(100% - 20px); }
  .topbar-inner { min-height: 51px; gap: 10px; flex-wrap: wrap; }
  .brand { gap: 7px; font-size: 17px; }
  .seal { width: 27px; height: 27px; font-size: 19px; }
  .camp-nav { order: 4; margin: -4px 0 0; width: 100%; height: 29px; gap: clamp(10px,3.5vw,21px); }
  .camp-nav a, .camp-nav button { font-size: 12px; }
  .purse, .roster-size { gap: 5px; font-size: 11px; }
  .purse strong,.roster-size strong { font-size: 16px; }
  .roster-size { padding-left: 9px; }
  .topbar-inner { padding-top: 8px; }
  main { padding-top: 10px; }
  .masthead { min-height: 110px; }
  .masthead::before { background-position: center, 58% 60%; }
  .masthead-copy { padding: 14px; }
  .masthead h1 { font-size: 38px; }
  .masthead p { font-size: 12px; margin-top: 5px; }
  .board { padding: 11px; }
  .board-heading { margin-bottom: 11px; }
  .board-title { gap: 7px; }
  .board-title h2 { font-size: 22px; }
  #stage { padding: 2px 4px; font-size: 10px; }
  .fortress { font-size: 11px; gap: 3px; }
  .fortress meter { width: 22px; }
  .machine { padding: 5px; }
  .grid { grid-template-columns: 20px repeat(2,minmax(0,.88fr)) minmax(0,1.04fr) minmax(0,2.3fr); }
  .labels { font-size: 10px; padding: 1px 0 5px; }
  .labels span:last-child { padding-left: 12px; }
  .line-no { font-size: 10px; }
  #rows { gap: 5px; }
  .row { height: 59px; }
  .row .symbol { flex-direction: column; gap: 0; }
  .row .rune { width: 33px; height: 37px; }
  .row .rune-label { display: flex; font-size: 11px; align-items: center; gap: 2px; }
  .row .stamp { margin-top: 0; font-size: 9px; }
  .row .result { padding: 0 2px; margin-left: 3px; border-left-width: 2px; }
  .row .recruit-art { width: clamp(33px, 9vw, 49px); }
  .row .name { font-size: clamp(14px,4vw,19px); gap: 3px; }
  .row .element { font-size: 9px; padding: 0 2px; }
  .row .stats { display: flex; flex-wrap: wrap; gap: 0 4px; font-size: 10px; margin-top: 2px; }
  .zoom-cue { font-size: 9px; margin-left: 2px; }
  .row[tabindex="0"] .result::after { top: 2px; right: 2px; transform: scale(.65); transform-origin: top right; }
  .placeholder { font-size: 11px; gap: 7px; padding-left: 6px; }
  .actions { margin: 10px 0 7px; gap: 5px; }
  .actions a,.actions button { min-height: 41px; flex-grow: 1; padding: 5px 7px; font-size: 12px; gap: 3px; }
  .actions #buyRecruit { margin-left: 0; }
  .hint,#resultShelf:not([hidden]) { font-size: 11px; }
  .field-guide { padding: 11px 12px; }
  .field-guide dl { column-gap: 11px; }
  .field-guide img { width: 29px; height: 30px; }
  .field-guide dt { font-size: 12px; gap: 2px; }
  .field-guide dd { font-size: 10px; }
}
@media (max-width: 360px) {
  .board-title h2 { font-size: 18px; }
  .board { padding: 8px; }
  .grid { grid-template-columns: 16px repeat(2,minmax(0,.8fr)) minmax(0,.98fr) minmax(0,2.5fr); }
  .row .recruit-art { width: 31px; }
  .row .stats { font-size: 10px; }
  .labels { font-size: 9px; }
  .actions a,.actions button { font-size: 11px; padding-inline: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
